package com.superzqb.asus.superzqbFragment.superzqbJobShop.Adapter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.superzqb.asus.superzqb.R;
import com.superzqb.asus.superzqbFragment.superzqbJobShop.Bean.CampusEnterpriseListBean;

import java.util.List;
import java.util.Map;


/**
 * Created by asus on 2017/1/21.
 */

public class ConcurrentStudentAdapter extends BaseAdapter {

    private Context context;
    private  List<CampusEnterpriseListBean> list;
    private int select =-1;
    private int[] color = {Color.rgb(255, 185, 0),
            Color.rgb(0, 187, 155), Color.rgb(25, 148, 250),
            Color.rgb(232, 76, 60)};
    public ConcurrentStudentAdapter(Context context,   List<CampusEnterpriseListBean> list) {
        this.context = context;
        this.list = list;
    }
    public void setList( List<CampusEnterpriseListBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return list == null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if(convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.campus_concurrent_student_item,parent,false);
            convertView.setTag(new ViewHolder(convertView));
        }
        ViewHolder holder=(ViewHolder) convertView.getTag();
        CampusEnterpriseListBean map=list.get(position);
        GradientDrawable myGrad = (GradientDrawable)holder.type.getBackground();
        myGrad.setColor(color[position%4]);
        holder.shopName.setText(map.getPosition());
        holder.type.setText(map.getType());
        holder.salary.setText(map.getSalary()+"元/小时");
        holder.address.setText(map.getAddress());
        holder.createTime.setText(map.getCreatetime());
        return convertView;
    }

    public void changeColor(int position) {
        this.select=position;
    }


     class ViewHolder{
        private TextView type,shopName,salary,address,createTime;
        public ViewHolder(View view){
            type=(TextView)view.findViewById(R.id.type);
            shopName=(TextView)view.findViewById(R.id.shopName);
            address=(TextView)view.findViewById(R.id.address);
            salary=(TextView)view.findViewById(R.id.salary);
            createTime=(TextView)view.findViewById(R.id.createTime);
        }

    }
}
